/**
 * 
 */
package ru.amse.stroganova.ui.command;

import java.awt.Point;

import ru.amse.stroganova.presentation.GraphPresentation;
import ru.amse.stroganova.presentation.VertexPresentation;
import ru.amse.stroganova.ui.visual.GraphElementSelection;

class AddVertexCommand implements Command {

	private final GraphPresentation graphPresentation;
	
	private final GraphElementSelection graphSelection;
	
	private VertexPresentation vertexPres;

	/**
	 * Creates new AddVertexCommand.
	 * 
	 * @param center
	 *            point
	 * @param graphPresentation 
	 * @param graphSelection
	 */
	public AddVertexCommand(Point center, GraphPresentation graphPresentation, GraphElementSelection graphSelection) {
		this.graphSelection = graphSelection;
		this.graphPresentation = graphPresentation;
		vertexPres = new VertexPresentation(center);
	}

	public void execute() {
		graphSelection.unselect();
		graphPresentation.addVertex(vertexPres);
		graphSelection.selectVertex(vertexPres);
	}

	public void undo() {
		graphSelection.unselect();
		graphPresentation.removeVertex(vertexPres);
	}
}